package com.bestv.bsr.core.service.impl.jt.remote;

import com.bestv.bsr.core.service.impl.jt.dto.JTRequestParam;
import com.bestv.bsr.core.service.impl.jt.dto.response.JTSearchResponseDto;
import com.bestv.bsr.core.service.impl.jt.dto.response.JTSimilarResponseDto;
import com.bestv.bsr.core.service.impl.jt.dto.response.JTTopicResponseDto;
import com.bestv.bsr.core.service.impl.jt.remote.fallback.JTSearchFallbackHandler;
import com.bestv.bsr.core.service.impl.jt.remote.fallback.JTSimilarFallbackHandler;
import com.bestv.bsr.core.service.impl.jt.remote.fallback.JiuTianTopicFallbackHandler;
import com.bestv.bsr.core.service.impl.jt.validate.JTValidGroups;
import com.bestv.remote.annotation.RemoteFunction;
import com.bestv.remote.annotation.RemoteParam;
import com.bestv.remote.annotation.RemoteService;
import com.bestv.remote.enums.ParamType;
import org.springframework.http.HttpMethod;
import org.springframework.validation.annotation.Validated;

/**
 * todo 配置不启动时不加载
 * <p>
 * 九天智能推荐远程服务
 *
 * @author taojiacheng
 */
@RemoteService(serviceId = "jtRemoteService", baseUrl = "${recommend.jt.baseurl}", targetServerName = "JT")
public interface JTRemoteService {

    /**
     * 九天头部主题推荐
     *
     * @param province province
     * @param param    推荐参数
     * @return 推荐结果
     */
    @RemoteFunction(value = "/{province}/v2/recommend/topicdetail", method = HttpMethod.POST,
            fallback = JiuTianTopicFallbackHandler.class, sentinelResource = "JT", block = JiuTianTopicFallbackHandler.class)
    JTTopicResponseDto recommendTopicDetail(@RemoteParam(name = "province", type = ParamType.PATH) String province,
                                            @RemoteParam(name = "requestParam", type = ParamType.JSON_BODY) @Validated(JTValidGroups.TOPIC_DETAIL_VALID.class) JTRequestParam requestParam);


    /**
     * 相似媒资推荐接口
     *
     * @param province province
     * @param param    推荐参数
     * @return 推荐结果
     */
    @RemoteFunction(value = "/{province}/v2/recommend/similarvideo", method = HttpMethod.POST,
            fallback = JTSimilarFallbackHandler.class, sentinelResource = "JT", block = JTSimilarFallbackHandler.class)
    JTSimilarResponseDto similarVideo(@RemoteParam(name = "province", type = ParamType.PATH) String province,
                                      @RemoteParam(name = "requestParam", type = ParamType.JSON_BODY) @Validated(JTValidGroups.SIMILAR_VIDEO_VALID.class) JTRequestParam requestParam);


    /**
     * 搜索接口
     *
     * @param province province
     * @param param    推荐参数
     * @return 推荐结果
     */
    @RemoteFunction(value = "/{province}/v2/recommend/search", method = HttpMethod.POST,
            fallback = JTSearchFallbackHandler.class, sentinelResource = "JT", block = JTSearchFallbackHandler.class)
    JTSearchResponseDto search(@RemoteParam(name = "province", type = ParamType.PATH) String province,
                               @RemoteParam(name = "requestParam", type = ParamType.JSON_BODY) @Validated(JTValidGroups.SEARCH_VALID.class) JTRequestParam requestParam);
}
